package com.zhixin.zhixinmall.config;

import java.io.IOException;
import java.time.LocalDateTime;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import cn.hutool.core.date.DateUtil;

/**
 * @author cyc
 * @date 2023/10/08 14:56:17
 */
public class CustomDateTimeSerializer extends JsonSerializer<LocalDateTime> {

    @Override
    public void serialize(LocalDateTime localDateTime, JsonGenerator jsonGenerator,
            SerializerProvider serializerProvider) throws IOException {
        jsonGenerator.writeString(DateUtil.format(localDateTime, "yyyy-MM-dd HH:mm:ss"));
    }

}
